<html lang="en">

<head th:include="templates/common :: header" />

<body>
	<div class="container" style="margin-top: 40px;">
		<div th:include="templates/common :: menu" ></div>	
		
		<div class="alert alert-success" th:if="${not #strings.isEmpty(status) and status == 'teachers.create.success'}">
				<a class="close">x</a>
				<p class="status" th:if="${not #strings.isEmpty(status)}" th:utext="#{${status}}">Status</p>
			</div>
			
			<div class="alert alert-danger" th:if="${not #strings.isEmpty(status) and status == 'teachers.create.failure'}">
				<a class="close">x</a>
				<p class="status" th:if="${not #strings.isEmpty(status)}" th:utext="#{${status}}">Status</p>
			</div>

			<div class="alert alert-success" th:if="${not #strings.isEmpty(status) and status == 'teachers.update.success'}">
				<a class="close">x</a>
				<p class="status" th:if="${not #strings.isEmpty(status)}" th:utext="#{${status}}">Status</p>
			</div>
			
			
			<div class="alert alert-danger" th:if="${not #strings.isEmpty(status) and status == 'teachers.update.failure'}">
				<a class="close">x</a>
				<p class="status" th:if="${not #strings.isEmpty(status)}" th:utext="#{${status}}">Status</p>
			</div>
			
			<div class="alert alert-success" th:if="${not #strings.isEmpty(status) and status == 'teachers.delete.success'}">
				<a class="close">x</a>
				<p class="status" th:if="${not #strings.isEmpty(status)}" th:utext="#{${status}}">Status</p>
			</div>
			
			<div class="alert alert-danger" th:if="${not #strings.isEmpty(status) and status == 'teachers.delete.failure'}">
				<a class="close">x</a>
				<p class="status" th:if="${not #strings.isEmpty(status)}" th:utext="#{${status}}">Status</p>
			</div>
			
			<div class="alert alert-danger" th:if="${not #strings.isEmpty(status) and status == 'teachers.not.found'}">
				<a class="close">x</a>
				<p class="status" th:if="${not #strings.isEmpty(status)}" th:utext="#{${status}}">Status</p>
			</div>
			
			<div class="alert alert-danger" th:if="${not #strings.isEmpty(status) and status == 'teachers.constraint.exception'}">
				<a class="close">x</a>
				<p class="status" th:if="${not #strings.isEmpty(status)}" th:utext="#{${status}}">Status</p>
			</div>
			
			<div class="alert alert-success" th:if="${not #strings.isEmpty(status) and status == 'teachers.password.reset.success'}">
				<a class="close">x</a>
				<p class="status" th:if="${not #strings.isEmpty(status)}" th:utext="#{${status}}">Status</p>
			</div>
			
			<div class="alert alert-danger" th:if="${not #strings.isEmpty(status) and status == 'teachers.password.reset.failure'}">
				<a class="close">x</a>
				<p class="status" th:if="${not #strings.isEmpty(status)}" th:utext="#{${status}}">Status</p>
			</div>
			
 		<div class="panel panel-primary" >		
	 		<div class="panel-body">				
				<div style="float:right; margin-bottom:10px;" sec:authorize="hasAnyRole('Administrator')">
					<a class="btn btn-primary" th:href="@{/users/teachers/create}" th:inline="text">
						<i class="glyphicon glyphicon-plus-sign" style="margin-right:5px;"/>[[#{teachers.create}]]
					</a>
				</div>

				<form id="teacherSearchForm" action="#" th:object="${searchHelper}" th:action="@{/users/teachers/__${beginIndex}__(order=${order}, column=${column}, searchString=${searchString})}" method="get" class="form-inline">
					<div class="col-lg-3">
						<input id="searchInput" type="text" th:field="*{searchString}" autofocus="autofocus" class="form-control" th:placeholder="#{app.search.label}" />
					</div>
					<button id="sumbitSearch" type="submit" class="btn btn-primary" th:inline="text"> 
						<i class="glyphicon glyphicon-search" style="margin-right: 5px;" />[[#{app.search}]]
					</button>
				</form>
			</div>
		</div>
		
		<table class="table table-bordered table-striped table-condensed">
			<thead>
				<tr>
					<th scope="col" style="text-align: center !important;">
						<a th:if="${!#strings.isEmpty(searchHelper.searchString)}" th:href="@{'/users/teachers/'+${currentIndex}(order=${order} , column='login', searchString=${searchHelper.searchString})}" th:text="#{teachers.table.username}"/>
						<a th:if="${#strings.isEmpty(searchHelper.searchString)}" th:href="@{'/users/teachers/'+${currentIndex}(order=${order} , column='login')}" th:text="#{teachers.table.username}"/>						
					</th>
					<th scope="col" style="text-align: center !important;">
						<a th:if="${!#strings.isEmpty(searchHelper.searchString)}" th:href="@{'/users/teachers/'+${currentIndex}(order=${order} , column='firstName', searchString=${searchHelper.searchString})}" th:text="#{teachers.table.firstname}"/>
						<a th:if="${#strings.isEmpty(searchHelper.searchString)}" th:href="@{'/users/teachers/'+${currentIndex}(order=${order} , column='firstName')}" th:text="#{teachers.table.firstname}"/>						
					</th>
					<th scope="col" style="text-align: center !important;">
						<a th:if="${!#strings.isEmpty(searchHelper.searchString)}" th:href="@{'/users/teachers/'+${currentIndex}(order=${order} , column='lastName', searchString=${searchHelper.searchString})}" th:text="#{teachers.table.lastname}"/>
						<a th:if="${#strings.isEmpty(searchHelper.searchString)}" th:href="@{'/users/teachers/'+${currentIndex}(order=${order} , column='lastName')}" th:text="#{teachers.table.lastname}"/>						
					</th>
					<th scope="col" style="text-align: center !important;">
						<a th:if="${!#strings.isEmpty(searchHelper.searchString)}" th:href="@{'/users/teachers/'+${currentIndex}(order=${order} , column='email', searchString=${searchHelper.searchString})}" th:text="#{teachers.table.email}"/>
						<a th:if="${#strings.isEmpty(searchHelper.searchString)}" th:href="@{'/users/teachers/'+${currentIndex}(order=${order} , column='email')}" th:text="#{teachers.table.email}"/>						
					</th>
					<th scope="col" style="text-align: center !important;">
						<a th:if="${!#strings.isEmpty(searchHelper.searchString)}" th:href="@{'/users/teachers/'+${currentIndex}(order=${order} , column='status', searchString=${searchHelper.searchString})}" th:text="#{account.status}"/>
						<a th:if="${#strings.isEmpty(searchHelper.searchString)}" th:href="@{'/users/teachers/'+${currentIndex}(order=${order} , column='status')}" th:text="#{account.status}"/>						
					</th>
					<th scope="col" style="text-align: center !important;"></th>
				</tr>
			</thead>
			<tbody>
				<tr th:each="user : ${users}">
					<td th:text="${user.userName}" style="text-align: center; vertical-align: middle;"></td>
					<td th:text="${user.firstName}" style="text-align: center; vertical-align: middle;"></td>
					<td th:text="${user.lastName}" style="text-align: center; vertical-align: middle;"></td>
					<td th:text="${user.email}" style="text-align: center; vertical-align: middle;"></td>							
					<td style="text-align: center; vertical-align: middle;"> 
						<i th:class="${ #bools.isTrue(user.status)} ? 'glyphicon glyphicon-eye-open' : 'glyphicon glyphicon-eye-close'"/>
					</td>							
					<td style="text-align: center; vertical-align: middle;">
						<a class="btn btn-success btn-small" th:href="@{/users/__${user.id}__/profile}" th:inline="text">
							<i class="glyphicon glyphicon-list-alt icon-white" style="margin-right:5px;"/>[[#{menu.profile}]]
						</a>
						<a class="btn btn-success btn-small" th:href="@{/users/teachers/subjects/__${user.id}__}" th:inline="text">
							<i class="glyphicon glyphicon-list-alt icon-white" style="margin-right:5px;"/>[[#{teachers.show.subjects}]]
						</a>
						<a class="btn btn-primary btn-small" th:href="@{/users/teachers/edit/__${user.id}__}" th:inline="text" sec:authorize="hasRole('Administrator')">
							<i class="icon-edit icon-white" style="margin-right:5px;"/>[[#{app.button.edit}]]
						</a>
						<a class="btn btn-danger btn-small" th:href="@{/users/teachers/delete/__${user.id}__}"  th:inline="text" sec:authorize="hasRole('Administrator')">
							<i class="icon-remove-sign icon-white" style="margin-right:5px;"/>[[#{app.button.delete}]]
						</a>
					</td>
				</tr>
			</tbody>
		</table>		
		
		<div style="text-align:center">
			<ul class="pager">
				<li class="disabled" th:if="${currentIndex == 1}"><a href="#">&lt;&lt;</a></li>
				<li class="disabled" th:if="${currentIndex == 1}"><a href="#">&lt;</a></li>
				<li th:if="${currentIndex != 1}">
					<a th:if="${!#strings.isEmpty(searchHelper.searchString)}" th:href="@{/users/__${beginIndex}__(order=${order}, column=${column}, searchString=${searchHelper.searchString})}">&lt;&lt;</a>
					<a th:if="${#strings.isEmpty(searchHelper.searchString)}" th:href="@{/users/__${beginIndex}__(order=${order}, column=${column})}">&lt;&lt;</a>
				</li>
				<li th:if="${currentIndex != 1}">
					<a th:if="${!#strings.isEmpty(searchHelper.searchString)}" th:href="@{/users/__${currentIndex-1}__(order=${order}, column=${column}, searchString=${searchHelper.searchString})}">&lt;</a>
					<a th:if="${#strings.isEmpty(searchHelper.searchString)}" th:href="@{/users/__${currentIndex-1}__(order=${order}, column=${column})}">&lt;</a>
				</li>

				<li class="disabled" th:if="${currentIndex == totalPages}"><a href="#">&gt;</a></li>
				<li class="disabled" th:if="${currentIndex == totalPages}"><a href="#">&gt;&gt;</a></li>
				<li th:if="${currentIndex != totalPages}">
					<a th:if="${!#strings.isEmpty(searchHelper.searchString)}" th:href="@{/users/__${currentIndex+1}__(order=${order}, column=${column}, searchString=${searchHelper.searchString})}">&gt;</a>
					<a th:if="${#strings.isEmpty(searchHelper.searchString)}" th:href="@{/users/__${currentIndex+1}__(order=${order}, column=${column})}">&gt;</a>
				</li>
				<li th:if="${currentIndex != totalPages}">
					<a th:if="${!#strings.isEmpty(searchHelper.searchString)}" th:href="@{/users/__${endIndex}__(order=${order} , column=${column}, searchString=${searchHelper.searchString})}">&gt;&gt;</a>
					<a th:if="${#strings.isEmpty(searchHelper.searchString)}" th:href="@{/users/__${endIndex}__(order=${order} , column=${column})}">&gt;&gt;</a>
				</li>
			</ul>
		</div>
		
	</div>		
</body>
</html>